package com.taxshare.seller.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author YANG
 * @date 2021/3/29
 */
@Component
@Slf4j
public class TransformationUtil {

    /**
     * 发票类型
     *
     * @param invoiceType
     * @return
     */
    public static String transInvoiceType(String invoiceType) {
        if ("004".equals(invoiceType)) {
            return "专票";
        } else if ("007".equals(invoiceType)) {
            return "普票";
        } else if ("026".equals(invoiceType)) {
            return "电票";
        }else if ("005".equals(invoiceType)) {
            return "机动车票";
        }  else {
            return "";
        }
    }

    /**
     * 开票类型
     *
     * @param makeInvoiceType
     * @return
     */
    public static String transMakeInvoiceType(String makeInvoiceType) {
        if ("0".equals(makeInvoiceType)) {
            return "蓝票";
        } else if ("1".equals(makeInvoiceType)) {
            return "红票";
        } else {
            return "";
        }
    }

    /**
     * 发票状态
     *
     * @param invoiceState
     * @return
     */
    public static String transInvoiceState(String invoiceState) {
        if ("0".equals(invoiceState)) {
            return "正常";
        } else if ("1".equals(invoiceState)) {
            return "作废";
        } else if ("2".equals(invoiceState)) {
            return "红冲";
        } else {
            return "";
        }
    }

    /**
     * 同步发票类型转换
     *
     * @param fplx
     * @return
     */
    public static String transSstInvoiceType(String fplx) {
        if ("0".equals(fplx)) {
            fplx = "004";
        } else if ("2".equals(fplx)) {
            fplx = "007";
        } if ("41".equals(fplx)) {
            fplx = "41";
        } else if ("51".equals(fplx)) {
            fplx = "026";
        } else if ("52".equals(fplx)) {
            fplx = "026";
        }
        return fplx;
    }

    /**
     * 同步发票类型转换(SST)
     *
     * @param fplx
     * @return
     */
    public static String transInvoiceTypeSST(String fplx) {
        if ("004".equals(fplx)) {
            fplx = "0";
        } else if ("007".equals(fplx)) {
            fplx = "2";
        } else if ("026".equals(fplx)) {
            fplx = "51";
        }
        return fplx;
    }
    /**
     * 同步明源订单发票类型转换
     *
     * @param invoiceType
     * @return
     */
    public static String documentInvoiceType(String invoiceType) {
        if ("增值税(普)".equals(invoiceType)) {
            invoiceType = "007";
        } else if ("增值税(专)".equals(invoiceType)) {
            invoiceType = "004";
        }
        return invoiceType;
    }

    /**
     * 客户类型转换
     *
     * @param type
     * @return
     */
    public static String companyType(String type) {
        if ("公司".equals(type)) {
            type = "1";
        } else if ("个人".equals(type)) {
            type = "2";
        }
        return type;
    }

    /**
     * 红字信息状态转换
     *
     * @param type
     * @return
     */
    public static String redTicketState(String type) {
        if ("TZD0072".equals(type)) {
            type = "1";
        } else if ("TZD0085".equals(type)) {
            type = "2";
        } else if ("TZD0074".equals(type)) {
            type = "4";
        } else if ("TZD0000".equals(type)) {
            type = "0";
        } else if ("TZD0100".equals(type)) {
            type = "4";
        }
        return type;
    }
}
